#pragma once
#include <iostream>
#include "RBTree.h"

template<class K>
class set
{
	struct SetKeyofT
	{
		const K& operator()(const K& key)
		{
			return key;
		}
	};
public:
	typedef typename RBTree<K, const K, SetKeyofT>::const_iterator iterator;
	typedef typename RBTree<K, const K, SetKeyofT>::const_iterator const_iterator;

	iterator find(const K& key)
	{
		return _t.find(key);
	}

	iterator begin() 
	{
		return _t.begin();
	}

	iterator end() 
	{
		return _t.end();
	}

	const_iterator begin() const
	{
		return _t.begin();
	}

	const_iterator end() const
	{
		return _t.end();
	}


	

	std::pair<iterator, bool> insert(const K& key)
	{
		return _t.insert(key);
	}

	void InOrder()
	{
		_t.InOrder();
	}

	
private:
	RBTree<K, const K, SetKeyofT> _t;
};

void Set_test1()
{
	set<int> s;
	//int arr[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	int arr[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };


	for (auto e : arr)
	{
		s.insert(e);
	}
	set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		std::cout << *it << std::endl;
		++it;
	}


	//s.InOrder();
	/*std::cout << t.IsBalance() << std::endl;
	std::cout << t.Size() << std::endl;*/
	//std::cout << t.Height() << std::endl;
}